const AdminBiz = require('../../../../../../comm/biz/admin_biz.js');
const pageHelper = require('../../../../../../helper/page_helper.js');
const cloudHelper = require('../../../../../../helper/cloud_helper.js');

Page({

	/**
	 * 页面的初始数据
	 */
	data: {
    id: '',
    isLoad: true,
    message: '',
    people: ''
	},

	/**
	 * 生命周期函数--监听页面加载
	 */
	async onLoad(options) {
    if (!AdminBiz.isAdmin(this)) return;
    console.log(options);
    if (!pageHelper.getOptions(this, options)) return;
    
    pageHelper.getOptions(this, options, 'people');
    //this._loadDetail();

	},

	/**
	 * 生命周期函数--监听页面初次渲染完成
	 */
	onReady() {

	},

	/**
	 * 生命周期函数--监听页面显示
	 */
	onShow() {

	},

	/**
	 * 生命周期函数--监听页面隐藏
	 */
	onHide() {

	},

	/**
	 * 生命周期函数--监听页面卸载
	 */
	onUnload() {

	},

	/**
	 * 页面相关事件处理函数--监听用户下拉动作
	 */
	async onPullDownRefresh() {
		//await this._loadDetail();
		//wx.stopPullDownRefresh();
	},

	/**
	 * 页面上拉触底事件的处理函数
	 */
	onReachBottom() {

	},

	/**
	 * 用户点击右上角分享
	 */
	onShareAppMessage() {

	},

	bindCustomTap: async function (e) {
		try {

			let params = {
        TASK_USER_ID: this.data.id,
        MESSAGE: this.data.message,
			}

      await wx.request({
        url: 'https://www.centurylt.co/weixin/custom',
        method: 'POST',
        data: params,
        success(res) {
          let callback = () => {
            wx.reLaunch({ url: '../list/admin_task_list' });
          }
          pageHelper.showSuccToast('发送成功', 1000, callback);
        }
      });
			

		} catch (err) {
			console.log(err);
			pageHelper.showNoneToast('发送失败，请重试');
		}

  },
  
	url(e) {
		pageHelper.url(e, this);
	}
})